home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0068_Set the VGA Palette.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  1KB  |  75 lines

  1. {
  2. JOHN BECK
  3.  
  4. > question me is that when I'm using the BIOS block palette
  5. > to create a fade in/out, it makes the screen flicker, which
  6. > is quite disturbing.  What Info I need is how the VGA port
  7. > works on setting up the RGB palette.  Thanks.
  8. }
  9.  
  10. Type
  11.   colorType  = Record
  12.     rvalue,
  13.     gvalue,
  14.     bvalue : Byte;
  15.   end;
  16.  
  17.   paletteType = Array [0..255] of colorType;
  18.  
  19. Procedure setpal(Var tp : paletteType);
  20. Var
  21.   palseg,
  22.   palofs : Word;
  23.  
  24. Label wait1 {,wait2};
  25.  
  26. begin
  27.   palseg := seg(tp);
  28.   palofs := ofs(tp);
  29.   Asm
  30.     mov  dx, $3DA
  31.  
  32.    wait1:
  33.     in   al, dx
  34.     test al, $08
  35.     jz   wait1
  36.  
  37.  { wait2:
  38.     in   al,dx
  39.     test al,$08
  40.     jnz  wait2 }
  41.  
  42.     mov ax, 1012h
  43.     xor bx, bx
  44.     mov cx, 256
  45.     mov es, palseg
  46.     mov dx, palofs
  47.     int 10h
  48.   end;
  49. end;
  50.  
  51. Procedure readpal(Var tp : paletteType);
  52. Var
  53.   palseg,
  54.   palofs : Word;
  55. begin
  56.   palseg := seg(tp);
  57.   palofs := ofs(tp);
  58.   Asm
  59.     mov ax, 1017h
  60.     xor bx, bx
  61.     mov cx, 256
  62.     mov es, palseg
  63.     mov dx, palofs
  64.     int 10h
  65.   end;
  66. end;
  67.  
  68. {
  69.    I cheat a little bit in the way that the screen flickering is handled,
  70. but I find that this way is faster For many animations+palette manipulations /
  71. second While still eliminating screen flickering.  Normally there would be
  72. two tests for retrace, a 'jz' and a 'jnz', instead this only performs the
  73. 'jz' test. if your monitor still flickers, uncomment the other code.
  74. }
  75.